import { IReport } from '@/interface/reports';
import {
  IAddArticleParam,
  IAddCommentParam,
  IAddReply,
  IArticleParams,
  IGoodSaveParam,
  IRequestArticleParam,
} from '../interface/Article';
import * as request from './request';

// export async function getArticles(body: IRequestArticleParam) {
//   try {
//     const data = await request.post(JSON.stringify(body), '/api/console/article/get')
//     return data
//   } catch (e) {
//     return (e)
//   }
// }

export async function getDetailArticle(body: { articleId: string }) {
  try {
    const data = await request.post(
      JSON.stringify(body),
      '/api/web/article/getDetail',
    );
    return data;
  } catch (e) {
    return e;
  }
}

export async function getAllArticles(body: IArticleParams) {
  try {
    const login = sessionStorage.getItem('login')?.toString();
    if (login === '1') {
      const data = await request.post(
        JSON.stringify(body),
        '/api/console/article/get',
      );
      return data;
    } else {
      return {};
    }
  } catch (e) {
    return e;
  }
}

export async function changeStatus(body: { id: string }) {
  try {
    const data = await request.post(
      JSON.stringify(body),
      '/api/console/article/changeStatus',
    );
    return data;
  } catch (e) {
    return e;
  }
}
